using System;
using System.Collections.Generic;
using System.Text;
using PH.Common;

namespace Hoshimi
{
    public class IPCreatorBot_MoveState : State
	{
		#region Singleton

		// Fields
		protected static IPCreatorBot_MoveState instance;

		// Constructor
		protected IPCreatorBot_MoveState() : base() { }

		// Methods
		public static IPCreatorBot_MoveState Instance()
		{
			// Uses "Lazy initialization"
			if( instance == null ) 
				instance = new IPCreatorBot_MoveState();

			return instance;
		}

		#endregion

		public override bool Play( Unit unit )
		{
			IPCreatorBot bot = (IPCreatorBot) unit;

            bot.SetName("Move");

			if(bot.UpdateAZNPoint())
			{
				bot.StopIfMoving();
			}

			if( bot.State == NanoBotState.Moving ) 
			{
				return true;
			}

			if(bot.IsAZNPointReached())
			{
				unit.myStateMachine.ChangeState( IPCreatorBot_OpenIPState.Instance() );
			}


			bot.MoveToAZNPoint();
            return true;
		}
	}
}